xlv.obj.accordion={
	extend:function(){
		this.extend('xlv.obj.ulli');
	},
	implement:function(){
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.accordion');
		Element.addClassName(div,'class_accordion');
		return div;			
	},
	properties:{
		editable:false,
		dmName:null,
		dmPath:null,
		ulLevel:2
	},
	method:{
		initial:function(){
			this.$super('xlv.obj.ulli.initial');
			Element.addClassName(this,'class_accordion');
			this.addEventHandler('mousedown', '_mousedown');
		},
		_mousedown:function(event){
			var li=this.targetElement(event.target,{tag:'li'},{tag:'ul'});
			if(li)this.expand(li);
		},
		expand:function(item,force_expand){
			if(item && xlv.util.isTag(item,'li')&&xlv.util.levelOfDescendant(this,item,{tag:'ul'})==1){
				var ul=xlv.util.findDirectChild(item,{tag:'ul'});
				if(this.$P.dmName && ul && !ul._created){
					var indexes=xlv.util.indexesForLI(item);
					var dm=this.mvc_getModel();
					var node=dm.getNode(xlv.util.indexesToXPath(indexes),this._getRootNode(dm));
					this._createLIforChildren(dm,node,ul);
					ul._created=true;
				}
				var siblings=xlv.util.siblings(item,{tag:'li'});
				for(var i=0,n=siblings.length;i<n;++i){
					if(Element.hasClassName(siblings[i],'expanded')){
						Element.removeClassName(siblings[i],'expanded');
						var ul2=xlv.util.findDirectChild(siblings[i],{tag:'ul'});
						if(ul2){
							var save_overflow=ul2.style.overflow;
							ul2.style.overflow='hidden';
							var close={element:ul2,style:{height:0}};
							close.finished=function(){
								close.element.style.display='none';
								close.element.style.height='';
								close.element.style.overflow=save_overflow;
							};
							xlv.util.queueStyleEffect(close);
						}
					}
				}
				var effect,save_overflow;
				var ul=xlv.util.findDirectChild(item,{tag:'ul'});
				if(Element.hasClassName(item,'expanded')){
					Element.removeClassName(item,'expanded');
					if(ul){
						save_overflow=ul.style.overflow;
						effect={element:ul,style:{height:0}};
						effect.setup=function(){
							ul.style.overflow='hidden';
						};
						effect.finished=function(){
							ul.style.display='none';
							ul.style.height='';
							ul.style.overflow=save_overflow;
						};
						xlv.util.queueStyleEffect(effect);
					}
				}else{
					Element.addClassName(item,'expanded');
					if(ul) {
						save_overflow=ul.style.overflow;
						ul.style.display='none';
						ul.style.height='';
						var dim=Element.getDimensions(ul);
						effect={element:ul,style:{height:dim.height}};
						effect.setup=function(){
							ul.style.height='0px';
							ul.style.display='block';
							ul.style.overflow='hidden';
						};
						effect.finished=function(){
							ul.style.display='block';
							ul.style.height='';
							ul.style.overflow=save_overflow;
						};
						xlv.util.queueStyleEffect(effect);
					}
				}
			}
		},
		select_selectable:function(target){
			var ul=this.targetElement(target,{tag:'ul'});
			return (xlv.util.levelOfDescendant(this,ul,{tag:'ul'})==this.$P.ulLevel)?	this.targetElement(target,{tag:'li'}) : null;
		}
	}
};
